﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:AuthenticationService.Client.Controls" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:behaviors="clr-namespace:Common.Behaviors;assembly=Common">
    <Style TargetType="local:LoginControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:LoginControl">
                    <Border x:Name="corePart" Background="{TemplateBinding Background}" 
                            BorderThickness="2" CornerRadius="0.1" 
                            BorderBrush="{TemplateBinding Foreground}" Padding="8">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="LoginStates">
                            	<VisualStateGroup.Transitions>
                            		<VisualTransition From="LoggedOut" GeneratedDuration="00:00:00" To="LoggingIn">
                            			<Storyboard>
                            				<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LoggingInContainer" Storyboard.TargetProperty="(UIElement.Visibility)">
                            					<DiscreteObjectKeyFrame KeyTime="00:00:00">
                            						<DiscreteObjectKeyFrame.Value>
                            							<Visibility>Visible</Visibility>
                            						</DiscreteObjectKeyFrame.Value>
                            					</DiscreteObjectKeyFrame>
                            				</ObjectAnimationUsingKeyFrames>
                            			</Storyboard>
                            		</VisualTransition>
                            		<VisualTransition From="LoggingIn" GeneratedDuration="00:00:00">
                            			<Storyboard>
                            				<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LoggingInContainer" Storyboard.TargetProperty="(UIElement.Visibility)">
                            					<DiscreteObjectKeyFrame KeyTime="00:00:00">
                            						<DiscreteObjectKeyFrame.Value>
                            							<Visibility>Collapsed</Visibility>
                            						</DiscreteObjectKeyFrame.Value>
                            					</DiscreteObjectKeyFrame>
                            				</ObjectAnimationUsingKeyFrames>
                            			</Storyboard>
                            		</VisualTransition>
                            	</VisualStateGroup.Transitions>
                                <VisualState x:Name="LoggedOut">
                                	<Storyboard>
                                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LoggingInContainer" Storyboard.TargetProperty="(UIElement.Visibility)">
                                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                                				<DiscreteObjectKeyFrame.Value>
                                					<Visibility>Collapsed</Visibility>
                                				</DiscreteObjectKeyFrame.Value>
                                			</DiscreteObjectKeyFrame>
                                		</ObjectAnimationUsingKeyFrames>
                                	</Storyboard>
                                </VisualState>
                                <VisualState x:Name="LoggingIn">
                                	<Storyboard>
                                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LoggingInContainer" Storyboard.TargetProperty="(UIElement.Visibility)">
                                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                                				<DiscreteObjectKeyFrame.Value>
                                					<Visibility>Visible</Visibility>
                                				</DiscreteObjectKeyFrame.Value>
                                			</DiscreteObjectKeyFrame>
                                		</ObjectAnimationUsingKeyFrames>
                                	</Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="LoginContainerPart" Background="{x:Null}">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Login" TextWrapping="Wrap" d:LayoutOverrides="Width, Height" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                            <Border x:Name="LoggingInContainer" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="3" Visibility="Collapsed">
                                <Border.Background>
                                    <SolidColorBrush Opacity="0.5" Color="Black"/>
                                </Border.Background>
                            </Border>
                            <TextBlock Margin="0,8,0,6" Text="Username: " TextWrapping="Wrap" d:LayoutOverrides="Width, Height" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                            <TextBox x:Name="UsernameTextbox" TextWrapping="Wrap" d:LayoutOverrides="Height" Grid.Row="1" 
                                     Grid.Column="1" HorizontalAlignment="Left" Width="120" 
                                     Margin="0,8,8,0" VerticalAlignment="Center"
                                     Text="{TemplateBinding Username}" TabIndex="0">
                            </TextBox>
                            <TextBlock HorizontalAlignment="Left" Margin="0,8,0,6" Grid.Row="2" Text="Password: " TextWrapping="Wrap" d:LayoutOverrides="Height" VerticalAlignment="Center"/>
                            <PasswordBox x:Name="PasswordTextbox" HorizontalAlignment="Left" d:LayoutOverrides="Height" 
                                         BorderThickness="1" Grid.Row="2" Grid.Column="1" Width="120" VerticalAlignment="Center" 
                                         Margin="0,8,0,0" Password="{TemplateBinding Password}">
                            </PasswordBox>
                            <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="1" Margin="0,8,8,0" HorizontalAlignment="Right">
                                <Button x:Name="CancelButton" Content="Cancel" d:LayoutOverrides="Height" HorizontalAlignment="Right" Margin="0,0,8,0"/>
                                <Button x:Name="LoginButton" Content="Login" d:LayoutOverrides="Height" HorizontalAlignment="Right"/>
                            </StackPanel>
                            <Button x:Name="GetPasswordButton" Margin="0,8,0,0" Content="What's my password?" d:LayoutOverrides="Height" Grid.Row="4" VerticalAlignment="Center" Grid.ColumnSpan="2" HorizontalAlignment="Left"/>
                            <Button x:Name="RegisterButton" HorizontalAlignment="Left" Margin="0,8,0,0" VerticalAlignment="Center" Content="Register Now" Grid.Row="5"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
